Managing data records

ABSTRACT

Data records may be managed in a relational database by monitoring, a record length for a first data record in a page of memory, an amount of free space in the page, and a page length. In response to receiving an operator command to replace the first data record with a second data record, a database management system may determine whether an estimated record length of a compressed second data record is outside of the amount of free space in the page. In response to determining the estimated record length of a compressed second data record is outside of the amount of free space in the page, the database management system may determine whether an estimated length of a compressed page is outside of the page length. In response to determining the estimated length of a compressed page is within the page length, the page may be compressed.

BACKGROUND

The present disclosure relates generally to data processing, and moreparticularly, to managing data records in a database. The amount of datathat needs to be managed by enterprises is growing at an increasingrate. As the amount of data continues to increase, the need toefficiently manage databases containing data records may also increase.

SUMMARY

Aspects of the disclosure may include a computer implemented method,system, and computer program product for managing data records in arelational database. The computer implemented method, system, andcomputer program product may include monitoring in the relationaldatabase a record length for a first data record in a page, an amount offree space in the page, and a page length of the page. The relationaldatabase may receive an operator command to replace the first datarecord with a second data record. Based upon receiving the operatorcommand, the computer implemented method, system, and computer programproduct may determine whether a record length of a compressed seconddata record is outside of the amount of free space in the page. Inresponse to determining that the record length of the compressed seconddata record is outside of the amount of free space in the page, thecomputer implemented method, system, and computer program product maydetermine whether a length of a compressed page which includes thesecond data record is outside of the page length. In response todetermining that the length of the compressed page is within the pagelength, the computer implemented method, system, and computer programproduct may compress the page including the second data record in therelational database.

The above summary is not intended to describe each illustratedembodiment or every implementation of the present disclosure.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

The drawings included in the present application are incorporated into,and form part of, the specification. They illustrate embodiments of thepresent disclosure and, along with the description, serve to explain theprinciples of the disclosure. The drawings are only illustrative ofcertain embodiments and do not limit the disclosure.

FIG. 1 depicts a high level block diagram of one embodiment of anexample system for managing data records in a relational database.

FIG. 2 depicts a block diagram of one embodiment of an example automatedcomputing machinery.

FIG. 3A depicts one embodiment of a page in a relational database beforereceiving an operator command.

FIG. 3B depicts one embodiment of a page in a relational database afterreceiving an operator command to replace a first data record with asecond data record.

FIG. 4A depicts one embodiment of a page in a relational database with acompressed second data record being outside of the amount of free spacein the same data page.

FIG. 4B depicts one embodiment of a compressed page in a relationaldatabase.

FIG. 5 depicts one embodiment of an example process for managing datarecords in a relational database.

While the embodiments described herein are amenable to variousmodifications and alternative forms, specifics thereof have been shownby way of example in the drawings and will be described in detail. Itshould be understood, however, that the particular embodiments describedare not to be taken in a limiting sense. On the contrary, the intentionis to cover all modifications, equivalents, and alternatives fallingwithin the spirit and scope of the invention.

DETAILED DESCRIPTION

Aspects of the present disclosure include a computer-implemented method,system, and computer program product for managing data records in arelational database. The computer-implemented method may includemonitoring, in a relational database, a record length for a first datarecord in a page, an amount of free space in the page, and a pagelength. In embodiments, the computer-implemented method may receive anoperator command to replace the first data record with a second datarecord. In response to receiving the operator command, thecomputer-implemented method may determine whether a record length of acompressed second data record is outside of the amount of free space inthe page. If the record length of the compressed second data record isoutside of the amount of free space in the page, thecomputer-implemented method may determine whether a compressed pagelength is outside of the page length. In embodiments, the compressedpage length may include the second data record. In response todetermining that the compressed page length is within the page length,the computer-implemented method may compress the page in the relationaldatabase. While the present disclosure is not necessarily limited tosuch applications, various aspects of the disclosure may be appreciatedthrough a discussion of various examples using this context.

Various embodiments of the present disclosure are directed towardsreducing performance degradation in a database. A database may includedata and metadata that may be stored on a persistent memory mechanism,such as, but not limited to, a set of hard disks. The data and metadatamay be stored in a database in a logical manner. For example, the dataand metadata may be stored according to relational and/orobject-relational database constructs. Database metadata may definedatabase objects, such as tables, object tables, views, or complextypes, such as object types and table functions. Structured QueryLanguage (SQL) data definition language (“DDL”) instructions are issuedto a database server to create or configure database objects.

Generally, data may be logically arranged within a database as one ormore data containers. A container may comprise records, and the datawithin each record may be organized into one or more fields. Inrelational database systems, the data containers are generally referredto as tables, the records are referred to as rows, and the fields arereferred to as columns. Other database architectures may use otherterminology. For the purpose of explanation, the examples andterminology used herein shall be commonly associated with relationaldatabases. Therefore, the terms “table”, “row”, and “column” shall beused herein to refer respectively to the data container, record, andfield.

A relational database may present information through a series of one ormore tables. Each table may include a series of rows and columns. Atable may be referred to as a relation in that a table is a collectionof objects of the same type (e.g., rows of customer information). Datarecords may be stored in a table according to common keys or concepts. Atable may consist of one or more pages. A page may be a fixed-lengthcontiguous block of virtual memory. In embodiments, the term page may beused interchangeably with the term block. Pages may have a predefinedfixed length, such as, but not limited to, 4K (kilobytes), 8 k, 16 k, or32K. Similarly, a data record may have a fixed length or a variablelength.

Typically, each new data record to be stored in a relational databasemay be inserted into the first available free space starting at thebeginning of a page. However, when a relational database receives anUPDATE SQL command, an updated data record meant to replace an originaldata record may no longer fit onto the page of the table. Typically, anUPDATE SQL command may modify multiple rows within a table. When anupdated data record is received and no longer fits into the page as aresult of an UPDATE SQL command, an overflow record may be created byinserting the updated data record into another page. An overflow recordmay be a row of data that may be small enough to fit on a single page ofmemory but may instead be stored across two or more pages. When anoverflow record is created, a pointer may be left in the original pageto mark where the updated record should be. By inserting a pointer inthe original page, the index entry in the index page may still point tothe position of the original data record, creating a need for additionalinput/output (I/O) operations if a simple request to retrieve that datarecord is received.

In the context of the UPDATE SQL command, percentage free space(PCTFREE) may be used to manage the issues associated with creating anoverflow record. PCTFREE may be a block storage parameter used tospecify how much space should be left in a database block for futureupdates. However, if PCTFREE is set too large, disk space may be wasted.Additionally, if PCTFREE is set too large, the buffer pool hit ratio(e.g., a measure of how often a page access is satisfied withoutrequiring an I/O operation) may decrease because, as a result ofreceiving a SELECT SQL command, more pages may need to be accessed dueto fewer records per page being transferred. Conversely, if PCTFREE istoo small or not set at all, many overflow records may be created inresponse to the relational database receiving UPDATE SQL commands.

If the PCTFREE is set incorrectly and needs to be modified, a databasemanagement system may perform a reorganization operation, either onlineor offline, to reclaim wasted space, improve database uptime or improvedata access speeds. Performing an online reorganization may causesignificant I/O operations and performing an offline reorganization maybe an unacceptable alternative. For databases with a large number oftables, a database administrator may not have time to manually determinethe right PCTFREE setting, resulting in a potentially incorrect PCTFREEsetting or no PCTFREE setting at all.

Aspects of the present disclosure may include a database managementsystem (DBMS) monitoring a record length for a first data record (Hereinused interchangeably with the term “first variable data record”) in apage, an amount of free space in the page, and a page length in arelational database. The following embodiments may be described in termsof a DB2® database environment and SQL commands (DB2 is a registeredtrademark of International Business Machines Corporation of Armonk,N.Y.) but are done only for illustrative purposes and are not to beconsidered limiting. For example, the computer-implemented method may beequally applicable to other relational databases such as Oracle,SyBase®, Microsoft's SQL Server®, Microsoft Access® and MySQL®. (SyBaseis a registered trademarks of Sybase, Inc. of Concord, Mass. SQL Serverand Microsoft Access are a registered trademarks of MicrosoftCorporation of Redmond, Wash. MySQL is a registered trademark of MySQLAB, a company of Knivsta, Sweden.)

In embodiments, the amount of free space in the page may includereserved or unused space in the page in the relational database. Invarious embodiments, the term ‘space’ may be used interchangeably withthe term ‘memory.’ The DBMS may receive an operator command to replacethe first data record with a second data record (Herein usedinterchangeably with the term “second variable data record”). Inembodiments, an operator command may define the different structureswithin a database and may be bound to functions which define operatorcommand behavior in specified contexts. In certain embodiments, anoperator command may correspond with modifier commands (e.g., insert,delete, and update commands). Receiving the operator command may furtherinclude comparing the record length of the second data record with theamount of free space in the page. Based upon comparing the record lengthof the second data record with the amount of free space in the page,DBMS may determine the record length of the second data record to bewithin the amount of free space in the page. In response to determiningthe record length of the second data record to be within the amount offree space in the page, the DBMS may replace the first data record withthe second data record, and may continuing monitoring the database.

If it is determined that the record length of the second data record isoutside of the amount of free space in the page, the DBMS may determinewhether a record length of a compressed second data record is outside ofor exceeds the amount of free space in the page. Determining whether arecord length of a compressed second data record is outside of theamount of free space in the page may further include estimating a recordlength of a compressed second data record. In response to estimating therecord length of a compressed second data record, the DBMS may comparethe estimated record length of a compressed second data record with theamount of free space in the page.

In embodiments, the DBMS may determine, based upon comparing theestimated record length of a compressed second data record with theamount of free space in the page, the record length of the compressedsecond data record is within or smaller than the amount of free space inthe page. Consequently, the DBMS may compress the second data record andmay replace the first data record with the compressed second data recordin the page in the relational database.

In various embodiments, the DBMS may determine, in response todetermining the record length of the compressed second data record isoutside of the amount of free space in the page, whether a compressedpage length is outside of the page length. In embodiments, a compressedpage length may include all of the data records stored within a page. Incertain embodiments, a compressed page length may include all of thedata records and metadata stored within a page. In further embodiments,the compressed page includes the second data record. Determining whethera compressed page length is outside of the page length may includeestimating a length of a compressed page and comparing, in response toestimating, the length of the compressed page with the page length.

Comparing the length of the compressed page with the page length mayinclude determining the length of the compressed page is within the pagelength. In response to determining that the length of the compressedpage is within the page length, the DBMS method may compress the page.When the page has been compressed, the compressed page may replace theuncompressed page. Conversely, the DBMS may determine that the length ofthe compressed page is outside of the page length. In response todetermining that the length of the compressed page is outside of thepage length, an overflow record may be created for the second datarecord.

FIG. 1 depicts a high level block diagram of a DBMS for managing datarecords in a relational database, according to embodiments. In theexample embodiment shown in FIG. 1, the DBMS 100 comprises a computersystem/server 102, the computer system/server 102 including a monitoringmodule 104, a comparison module 106, an estimation module 108, and acompression module 110. The DBMS 100 additionally includes a databasemodule 114 in communication with the computer system/server 102 througha network 112. In various embodiments, the database module 114 may be arelational database, described herein.

The computer system/server 102 may be operational with numerous othergeneral purpose or special purpose computing system environments orconfigurations. Examples of well-known computing systems, environments,and/or configurations that may be suitable for use with computersystem/server 102 may include, but are not limited to, personal computersystems, server computer systems, thin clients, thick clients, hand-heldor laptop devices, multiprocessor systems, microprocessor-based systems,set top boxes, programmable consumer electronics, network PCs,minicomputer systems, mainframe computer systems, and distributed cloudcomputing environments that include any of the above systems or devices,and the like.

The computer system/server 102 may be described in the general contextof computer system-executable instructions, such as program modules,being executed by a computer system. Generally, program modules mayinclude routines, programs, objects, components, logic, data structures,and so on that perform particular tasks or implement particular abstractdata types. The computer system/server 102 may be practiced indistributed cloud computing environments where tasks are performed byremote processing devices that are linked through a communicationsnetwork. In a distributed cloud computing environment, program modulesmay be located in both local and remote computer system storage mediaincluding memory storage devices (e.g., databases).

The computer system/server 102 may communicate with the database module114 through the network 112. The network 112 may include one or morenetworks such as a local area network (LAN), a general wide area network(WAN), and/or a public network (e.g., the Internet). The network 112 maybe a hub which other modules within the DBMS 100 may establish acommunication connection. In embodiments, the database module 114 may bean online database and/or an offline database. In embodiments, anoffline database may be a local database stored on a computer (e.g., aserver). Conversely, an online database may be stored in a shared poolof network configurable resources or it may be stored in an onlineserver (e.g., a server on the Internet).

The monitor module 104 may communicate through the network 112 to scanthe database module 114. In various embodiments, the monitor module 104may scan the database module 114 continuously. The monitor module 104may include database software. Database software may include applicationsoftware and/or system software, where system software may includeoperating systems, device drivers, or utilities (e.g., computer programsdesigned to assist users in maintenance). In certain embodiments, thedatabase software used by the monitor module 104 may be interfaced withthe database module 114 such that the monitor module 104 may manage andtrack the data stored in the database module 114. For example, themonitor module 104 may oversee the insertion, deletion, or modificationof data within the database module 114. In embodiments, the monitormodule 104 may monitor the record lengths of data records in thedatabase module 114, the amount of free space in the pages in thedatabase 114, and the page lengths in the database module 114. Forexample, the monitor module 104 may access the database index of thedatabase module 114 to identify a record soon to be changed in responseto receiving an UPDATE SQL command. In various embodiments, the monitormodule 104 may retrieve the data from the database module 114 forprocessing within the computer system/server 102. The monitor module 104may be in constant communication with the comparison module 106, theestimation module 108 and the compression module 110.

The comparison module 106 may utilize information collected from themonitoring module 104 to determine whether or not additional action isrequired by the computer system/server 102. In embodiments, additionalactions that may be required may include estimating lengths forcompressed data records and/or compressed pages, comparing estimatedcompressed record lengths with the amount of free space left in a page,and comparing estimated compressed page lengths with the page lengths.For example, the monitoring module 104 may, in response to tracking anUPDATE SQL command for a data record, access the database index of thedatabase module 114. Accessing the database index of the database module114 may include retrieving statistics associated with the data recordand the updated data record, such as the record length, the amount offree space remaining in the page where the data record is stored, andthe page length where the data record is stored. The statisticsassociated with the data records may be sent to the comparison module106 for processing.

For example, in processing, the comparison module 106 may compare therecord length of the updated data record with the amount of free spaceremaining in the page in the table. Continuing the example, if therecord length of the updated data record (e.g., second data record) doesnot go outside the amount of free space in the page, the UPDATE SQLcommand is carried out and the original data record (e.g., first datarecord) is replaced by the updated data record. Conversely, if therecord length of the updated data record does go outside the amount offree space in the page, the comparison module 106 may communicate thisinformation, including the record length of the update data record andthe amount of free space in the page, to the estimating module 108.

The comparison module 106 may be in constant communication with theestimating module 108. The estimating module 108 may invoke astand-alone utility (e.g., DSN1COMP in DB2® z/OS) within the databasemodule 114 to estimate space savings that may be achieved by compressingdata in a page in a table. In embodiments, the estimating module 108 mayestimate space savings that may be achieved by compressing a page in atable. In various embodiments, estimating space savings may includemultiplying the record length of a data record by a compression ratio.In certain embodiments, the compression ratio may be a ratio of the sizeof the encoded output data to the size of the original data. In furtherembodiments, the size of the encoded output data may be measured duringstorage or during transmission. Various methodologies for estimatingrecord lengths of compression ratios are envisioned and the examplesdescribed herein are for illustrative purposes only.

Continuing the example where the record length of the updated datarecord goes outside the amount of free space in the page, the estimatingmodule 108 may estimate the record length of a compressed updated datarecord. Once estimated, the estimating module 108 may send the estimatedrecord length of a compressed updated data record to the comparisonmodule 106 for processing. The comparison module 106 may compare therecord length of the estimated compressed updated data record with theamount of free space in the page. If the record length of the estimatedcompressed updated data record does not go outside of the amount of freespace in the page, the update data record is sent to the compressionmodule 110 for processing.

Conversely, if the record length of the estimated compressed updateddata record does go outside of the amount of free space in the page, theestimating module 108 may estimate the page length of a compressed page.In embodiments, compressing a page may include compressing data recordswithin a page, including the updated data record (e.g., second datarecord). In further embodiments, compressing a page may includecompressing all data within a page, including data records as well asmetadata. The estimated compressed page length may be sent to thecomparison module 106 to compare the compressed page length with thepage length of the target page. If the compressed page length does notgo outside of the page length, the page, including the updated datarecord, is sent to the compression module 110 for processing.Conversely, if the compressed page length does go outside of the pagelength, the computer system/server 102 may notify the database module114 to take additional action, such as, for example, create an overflowrecord for the updated data record or to perform a databasereorganization.

The compression module 110 may be in constant communication with themonitoring module 104, the comparison module 106, and the estimatingmodule 108. The compression module 110 may receive data records or pagesfrom the monitoring module 104 in response to determinations calculatedat the comparison module 106. In embodiments, the compression module 110may access the database module 114 through the network 112 to retrievedata records or pages in response to determinations calculated at thecomparison module 106. The compression module 110 may implement aplurality of compression techniques to compress data records or pages inresponse to determinations at other modules within the computersystem/server 102. In embodiments, the compression module 110 mayutilize hardware and/or software compression techniques to compress thedata records or pages, as discussed in more detail below. In certainembodiments, the compression module 110 may compress data records whilethe database module 114 is either online or offline.

In various embodiments, the software compression techniques may includedictionary-based compression, where phrases within data records arereplaced with pointers. Replacing the phrases with pointers may includebuilding an internal data table (e.g., a dictionary) by encoding thedata stored in the database. In embodiments, the dictionary-basedcompression may be adaptive or non-adaptive. For example, in using anadaptive dictionary-based compression technique for a non-compressedtable, when a database receives SQL commands such as INSERT, REORG,LOAD, UNLOAD, a background processor may begin to collect the datarequired to be able to encode the data to build up the internal datatable instead of having a predetermined internal data table with anon-adaptive dictionary-based compression technique. It is to beunderstood that other software compression techniques known to one ofskill in the art can be implemented in other embodiments.

In various embodiments, hardware compression techniques may be preferredover software compression techniques. In embodiments where the hardwarecompression techniques are utilized, the hardware compression techniquesmay utilize system provided hardware compression services (e.g., a tapelibrary) to perform compression on data records or pages. In furtherembodiments, the compression techniques may include row compression,page compression, or column compression, depending upon the type ofdatabase. If a data record or page has been compressed at thecompression module 110, the compressed data may be transferred to thedatabase module 114 to finish the SQL operator command which initiatedthe modules within the computer system/server 102. In embodiments, thecomputer system/server 102 and the database module 114 may be locatedwithin the same computer system, such as the example described in FIG.2. It is to be understood that other hardware compression techniquesknown to one of skill in the art can be implemented in otherembodiments.

FIG. 2 illustrates a block diagram of automated computing machinery,according to various embodiments. In the embodiment shown in FIG. 2, thecomputing machinery includes example computer 252 useful in performingaspects of the disclosure, according to various embodiments. Thecomputer 252 of FIG. 2 includes at least one computer processor unit 256or ‘CPU’ as well as random access memory 268 (‘RAM’) which is connectedthrough bus adapter 258 to processor 256 and to other components of thecomputer 252.

The RAM 268 may include a monitoring module 204, a comparison module206, an estimating module 208 and a compression module 210. Aspects ofthe present disclosure may be similar or the same as aspects describedin FIG. 1 with respect to the monitoring module 104, the comparisonmodule 106, the estimating module 108 and the compression module 110.The monitoring module 204, the comparison module 206, the estimatingmodule 208 and the compression module 210 may be programs stored withinthe RAM 268 executable by the processor 256. In various embodiments, themodules 204-210 may be loaded from the data storage 270 and executedwithin the data storage 270. In certain embodiments, the modules 204-210may be stored in one or more computing machineries and may be retrievedthrough a network, such as network 200, to be executed by the processor256.

The RAM 268 may include an operating system 254. Operating systemsuseful for record filtering according to embodiments discussed hereininclude, but are not limited to, UNIX® (UNIX is a registered trademarkof The Open Group in the United States and other countries), Linux®(Linux is a registered trademark of Linus Torvalds in the United States,other countries, or both), Microsoft XP™ (Microsoft and Windows aretrademarks of Microsoft Corporation in the United States, othercountries, or both), AIX®, IBM's i5/OS™, and others. The operatingsystem 254 is shown in RAM (268), but many components of such softwaretypically are stored in non-volatile memory also, such as, for example,on a data storage 270.

The computer 252 may also include disk drive adapter 272 coupled throughexpansion bus 260 and bus adapter 258 to processor 256 and othercomponents of the computer 252. Disk drive adapter 272 connectsnon-volatile data storage to the computer 252 in the form of datastorage 270. Disk drive adapters useful in computers include, but arenot limited to, Integrated Drive Electronics (‘IDE’) adapters, SmallComputer System Interface (‘SCSI’) adapters, and others. Non-volatilecomputer memory also may be implemented as an optical disk drive,electrically erasable programmable read-only memory (so-called ‘EEPROM’or ‘Flash’ memory), RAM drives, and so on.

The data storage 270 may include one or more storage devices in a tieredor non-tiered configuration. The data storage 270 may be a database,such as the database module 116 described in FIG. 1 or a relationaldatabase described herein. The data storage 270 may communicate with oneor more of the monitoring module 204, the comparison module 206, theestimating module 208, and the compression module 210.

The example computer 252 includes one or more input/output (‘I/O’)adapters 278. I/O adapters implement user-oriented input/output through,for example, software drivers and computer hardware for controllingoutput to display devices such as computer display screens, as well asuser input from user input devices 281 such as, but not limited to,keyboards and mice. The example computer 252 includes a video adapter209, which is an example of an I/O adapter specially designed forgraphic output to a display device 280 such as, but not limited to, adisplay screen or computer monitor. In this example, video adapter 209is connected to processor 256 through a high speed video bus 264, busadapter 258, and the front side bus 262, which is also a high speed busin this example.

The example computer 252 includes a communications adapter 267 for datacommunications with other computers 212, e.g., mobile devices, and fordata communications with a data communications network 200. Such datacommunications may be carried out serially through RS-232 connections,through external buses such as a Universal Serial Bus (‘USB’), throughdata communications networks such as IP data communications networks,and/or in other ways that are known to those of skill in the art.Communications adapters implement the hardware level of datacommunications through which one computer sends data communications toanother computer, directly or through a data communications network.Examples of communications adapters include, but are not limited to,modems for wired dial-up communications, Ethernet (IEEE 802.3) adaptersfor wired data communications network communications, and IEEE 802.77adapters for wireless data communications network communications.

FIG. 3A depicts one example of a page in a relational database 300before receiving an operator command, according to embodiments. Thedatabase 300 may include a plurality of tables, where each tableincludes one or more pages. The data page 302 may represent how a datarecord may be stored within a page. Data within a page may be subdividedinto one or more contiguous segments herein described as rows. When newdata is added to the database 300, each data row in the page correspondswith data from at least a portion of a table. However, there may notalways be a one-to-one correspondence between table rows and page rows.Although “rows” in a table and “rows” in a page are both known as“rows,” they may be considered two distinct concepts. Accordingly, wherenecessary, this application may use the terms “table rows” and “pagerows” to refer to “rows” of a table and “rows” of a page, respectively.

The data page 302 may include a page header 304. The page header 304 mayinclude information describing the data page 302 and/or the tablescorresponding with raw data stored within page 302. For example, thepage header 304 may include metadata such as a table directory thatdescribes various qualities of the tables and table rows for which thedata page 302 comprises data. In an additional example, the page header304 may include metadata such as a row directory indicating the startingaddress of and/or identifier for each data page row in the data page.The metadata in the page header 304 may, depending on the type ofdatabase, define and delimit the data page rows for the data page 302.Accordingly, in some databases, a data page row may be characterized asthe lowest level subdivision of a data page whose address is discernablefrom the data page header, or as any subdivision of the data page forwhich the data page header lists an identifier for the index page withinthe database.

The data page 302 may include a database control area 306. The databasecontrol area 306 may be a reserve space within the data page 302. Thereserve space within the data page 302 may include control information,such as the amount of PCTFREE remaining in the data page 302, the numberof identifications within the data page 302, or the amount of holes(e.g., reusable space where a data record once was but is no longerstored) in the data page 302. In certain embodiments, the databasecontrol area 306 may be a page row header. The database control area 306may delimit each data row. For example, the database control area 306may include a variety of metadata, including but not limited to anidentifier for the data page row, the number of columns that thedatabase 300 should expect to read from the data page row, and/or thesizes of each column in the data page row (e.g., to provide the database300 with the boundaries of each field in the data page row).

The data row N 308, where “N” is a row identifier, may be characterizedby the database control area 306 and/or the page header 304. Similarly,the first data record 310 may be characterized by the database controlarea 306 and/or the page header 304. The first data record 310 may be anillustrative example of a data record with a variable length. The freespace 312 may be an illustrative example of space allocated within apage to be used for storing data records. In various embodiments, thefree space 312 may be an illustrative example of PCTFREE. The length ofthe page 302 may include data row N 308, the first data record 310, andthe free space 312.

FIG. 3B depicts one example of the page in the illustrative relationaldatabase 300 after receiving an example operator command to replace afirst data record with a second data record, according to embodimentsdescribed herein. FIG. 3B is an illustrative example depicting anembodiment in which the data page 302 from FIG. 3A receives an operatorcommand 316 to replace the first data record 310 with a second datarecord 314. Aspects of FIG. 3B disclosure may be similar or the same asaspects described in FIG. 3A with respect to the database 300, the datapage 302, the page header 304, the database control area 306, the datarow N 308 and the free space 312.

The database 300 may receive an operator command 316 which affects thefirst data record 310 stored in the data page 302. The operator command316 may correspond with modifier commands (e.g., insert, delete, andupdate operator commands), as discussed above. For the purposes ofillustration, the discussion of FIG. 3A and FIG. 3B may make theassumption that the operator command 316 is an UPDATE SQL command andthe second data record 314 is an updated data record of the first datarecord 310. When the database 300 receives the operator command 316, itmay measure the length of the second data record 314 as well as theamount of free space 312 remaining in the page 302.

Block 310 is an illustrative example depicting the length of the firstdata record 310 in comparison to the second data record 314. The seconddata record 314 (e.g., updated first data record) may include datastored within the first data record 310. The second data record 314, asillustrated, may fit within the page 302 because the amount of freespace 312 within the page 302 exceeded the record length of the seconddata record 314. In embodiments, the record length of the second datarecord 314 may go outside of the amount of free space 312 remainingwithin the page 302. In response to determining that the record lengthof the second data record 314 goes outside of the amount of free space312 remaining within the page 302, the database 300 may determinewhether or not to compress the second data record, whether or not tocompress the page 302, or whether or not to create an overflow recordfor the second data record 314.

FIG. 4A depicts one example of a page in a relational database with acompressed second data record being outside of the amount of free spacein the same data page, according to embodiments. The data page 400 mayinclude a page N header 404, a database control area 406, a data row N408, and a compressed second data record 410. Aspects of the presentdisclosure may be similar or the same as FIG. 3A and FIG. 3B withrespect to the data page 302, the page header 304, the database controlarea 306, the data row N 308 and the free space 312.

In this example, the data page 400 contains a compressed second datarecord 410. In embodiments, the relational database containing the datapage 400 may have received an operator command to update a first datarecord with a second data record. In response to receiving the operatorcommand, the relational database, in this example, determined that thesecond data record goes outside of or exceeds the amount of free spacein the data page 400. Subsequently, in response to determining that thesecond data record goes outside of the amount of free space in the datapage 400, the database compressed the second data record in thisexample. However, as illustrated in this example, the compressed seconddata record 410 still goes outside of the amount of free space in thedata page 400, creating an additional page 402 to store the remainingcompressed second data record 411. In embodiments, the compressed seconddata record 410 and the compressed second data record 411 are portionsof the same data record. In various embodiments, the compressed seconddata record 411 may be the remaining data from the compressed seconddata record 410 which went outside of the amount of free space withinthe data page 400.

The data page 402 illustrates how a compressed second data record 410may overflow from the data page 400 to the data page 402. The data page402 may include similar attributes to the data page 400, such as a pageN+1 header 404, a database control area 406, a data row N 408. However,as shown, the data page 402 contains an amount of free space 412 becausethe compressed second data record 411 does not exceed the amount of freespace in the data page 402. The depictions in FIG. 4A may be anillustration as to how an overflow record may be created within adatabase, where the data page 400 utilizes the data page 402 to storeadditional data that could no longer be stored within the data page 400.

Storage of compression units (e.g., compressed data records) in a datapage may maintain compatibility with existing data pages in databases.In embodiments, this may allow the use of compressed data in preexistingdatabases without modification to the underlying format to the database.In various embodiments, the compressed data records and the compresseddata pages may co-exist with uncompressed data records and uncompressedpages. For example, the data page 400 may contain data which iscompressed (e.g., compressed second data record 410) and may containdata which is not compressed (e.g., data row N 408).

In certain embodiments, when the database receives a request that mayrequire the database server to access one or more compressed data rowswhich have been stored in one or more data pages, the database servermay locate where the compressed data rows have been stored. In responseto locating where the compressed data rows may have been stored, thedatabase server may decompress the compressed data rows (e.g., byperforming a reorganization operation) and place the resultingdecompressed matrix in a temporary buffer. Subsequently, the databaseserver may then locate the desired data records from the compressed datarows in the decompressed matrix.

FIG. 4B depicts a compressed page in a relational database, according toembodiments. The data page 400 in FIG. 4B may be created in response tothe relational database determining that a compressed second data recordis outside of the amount of free space in the page (e.g., FIG. 4A) andin response to determining that the compressed page length for the datapage 400 may be within the page length for the data page 400. The datapage 400 may include the same components as the data page 400 from FIG.4A, such as the page N header 404, the database control area 406, andthe data row N 408. However, the data page 400 includes a compresseddata 414 and an amount of free space 412. In embodiments, the compresseddata 414 may be all of the data and/or metadata stored within the datapage 400 from FIG. 4A, including the compressed second data record 410.

FIG. 5 depicts one embodiment of an example process for managing datarecords in a relational database, according to embodiments. At block502, the relational database is monitored by a database managementsystem (DBMS). In embodiments, the database management system maysupport an arbitrary number of databases, although for the sake ofexample, only one database is considered for this discussion. In variousembodiments, the DBMS may allow users to perform basic databaseoperations, such as: defining a database, altering the definition of thedatabase, creating, editing and removing records in the database,viewing records in the database, defining database indexes, and soforth. Monitoring the relational database at block 502 may includetracking the record lengths of data records stored within the databaseas well as tracking the amount of free space remaining within pagesstored within the database.

At block 504, the DBMS receives an operator command. The operatorcommand may be an SQL operator command, such as the modifier commandsinsert, merge, delete, and update or utility statements load, shrlevel,and change. For the sake of example, the following discussion assumesthat the SQL operator command is an UPDATE SQL operator command, howevervarious operator commands are envisioned and the example is not intendedto be limiting. In embodiments, the operator command may indicate that afirst data record needs to be replaced with a second data record.

In response to receiving an UPDATE SQL operator command, the DBMS makesa free space determination at block 506. In embodiments, a free spacedetermination may include measuring the record length of the second datarecord and comparing the record length of the second data record withthe amount of free space remaining in the page where the second datarecord may be stored. In various embodiments, the amount of free spaceremaining in the page may include the amount of space saved by replacinga first data record with a second data record. In certain embodiments,the second data record may include the first data record. If the DBMSdetermines that the record length of the second data record does not gooutside of the amount of free space remaining in the page, the DBMSreplaces the first data record with the second data record at block 508.In response to replacing the first data record with the second datarecord, the DBMS may continuing monitoring the relational database asdescribed at block 502.

If the DBMS determines that the record length of the second data recorddoes go outside of the amount of free space remaining in the page, theDBMS estimates the record length of a compressed second data record atblock 510, in this example. Aspects of the present disclosure may besimilar or the same as aspects described in FIG. 1 with respect to theestimating module 108. Estimating the record length of a compressedsecond data record may include generating statistics with and withoutperforming compression as well as the percentage of space the databaseexpects to save. In embodiments, estimating the record length mayinclude statistics such as the number of rows scanned to build adictionary to perform compression, the number of rows processed todeliver the statistics, the average row lengths before and aftercompression, the size of the dictionary in pages before and aftercompression, the size of the table space in pages before and aftercompression, and percentages of pages that may be saved.

Utilizing the statistics calculated at block 510, the DBMS makes acompressed record determination at block 512, in this example. Invarious embodiments, a compressed record determination may includecomparing the record length of the estimated compressed second datarecord with the amount of free space remaining in the page where thesecond data record may be stored. If the DBMS determines that the recordlength of the estimated compressed second data record does not gooutside of the amount of free space remaining in the page, the seconddata record may be compressed at block 514 utilizing compressiontechniques discussed herein (e.g., FIG. 1 with respect to thecompression module 110). In embodiments, in response to compressing thesecond data record, the DBMS replaces the first data record with thecompressed second data record. In further embodiments, in response toreplacing the first data record with the compressed second data record,the DBMS may continue to monitor the database as described at block 502.If the DBMS determines that the record length of the estimatedcompressed second data record does go outside of the amount of freespace remaining in the page, the DBMS estimates the page length of acompressed page where the second data record is stored at block 516.

Estimating the page length of a compressed page may utilize similar orthe same techniques used in estimating compressed record lengths atblock 510. In response to determining statistics pertaining to acompressed page at block 510, the DBMS makes a page length determinationat block 518. In embodiments, a page length determination may includecomparing the page length of an estimated compressed page with the pagelength of the original page. If the DBMS determines that the page lengthof an estimated compressed page does not go outside of the page lengthof a page (e.g., the original page), the DBMS compresses the page atblock 520 utilizing the same or similar compression techniques used atblock 514 as discussed herein (e.g., FIG. 1 with respect to thecompression module 110). In embodiments, in response to compressing thepage, including the second data record, the DBMS may continue to monitorthe relational database as discussed at block 502.

If the DBMS determines that the page length of an estimated compressedpage does go outside of the page length, the DBMS may optionally createan overflow record for the second data record at block 522. Variousembodiments of the process depicted in FIG. 5 are envisioned. Individualoperations at individual blocks discussed separately may be performedsimultaneously or temporarily. For example, the DBMS may be able toestimate the record length of a compressed second data record andestimate the page length of a compressed page, including the second datarecord, simultaneously. In another example, the DBMS may, instead ofestimating, temporarily compress the second data record or temporarilycompress the page containing the second data record and immediatelyafter compressing attempt to replace the first data record with thecompressed second data record or replace the page with the compressedpage.

The present invention may be a system, a method, and/or a computerprogram product. The computer program product may include a computerreadable storage medium (or media) having computer readable programinstructions thereon for causing a processor to carry out aspects of thepresent invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Smalltalk, C++ or the like, andconventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

The descriptions of the various embodiments of the present disclosurehave been presented for purposes of illustration, but are not intendedto be exhaustive or limited to the embodiments disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art without departing from the scope and spirit of the describedembodiments. The terminology used herein was chosen to explain theprinciples of the embodiments, the practical application or technicalimprovement over technologies found in the marketplace, or to enableothers of ordinary skill in the art to understand the embodimentsdisclosed herein.

What is claimed is:
 1. A computer implemented method for managing datarecords in a relational database, the method comprising: receiving anoperator command to replace a first data record with a second datarecord in a relational database, wherein the first data record isassociated with a record length, a page of memory, an amount of freespace in the page, and a page length of the page; determining, basedupon receiving the operator command, whether an estimated record lengthof a compressed second data record is outside of the amount of freespace in the page; and in response to determining that the estimatedrecord length of the compressed second data record is within the pagelength, compressing the second data record in the relational database.2. The method of claim 1, wherein receiving the operator commandincludes comparing the record length of the second data record with theamount of free space in the page.
 3. The method of claim 2, furthercomprising: determining, based on comparing the record length of thesecond data record with the amount of free space in the page, the recordlength of the second data record to be within the amount of free spacein the page; and replacing the first data record with the second datarecord.
 4. The method of claim 1, wherein determining whether anestimated record length of a compressed second data record is outside ofthe amount of free space in the page further comprises: comparing therecord length of the second data record with the amount of free space inthe page; estimating, in response to comparing, a record length of acompressed second data record; and comparing, in response to estimating,the estimated record length of the compressed second data record withthe amount of free space in the page.
 5. The method of claim 4, furthercomprising: determining, based upon the comparing, the estimated recordlength of the compressed second data record is within the amount of freespace in the page; compressing the second data record; and replacing thefirst data record with the compressed second data record.
 6. The methodof claim 1, wherein determining whether the estimated record length of acompressed second data record is outside of the page length furthercomprises: estimating a length of a compressed page; and comparing, inresponse to estimating, the estimated record length of the compressedpage with the page length.
 7. The method of claim 6, wherein in responseto determining that the estimated record length of the compressed pageis within the page length, the method further comprises: compressing thepage; and replacing the page with a compressed page.
 8. The method ofclaim 6, wherein comparing the estimated record length of the compressedpage with the page length further comprises: determining the estimatedrecord length of the compressed page is outside of the page length; andcreating an overflow record for the second data record.
 9. The method ofclaim 1, wherein the operator command corresponds with modifiercommands, the modifier commands including update operators.
 10. Themethod of claim 1, wherein the amount of free space in the page includesreserved or unused space in the page in the relational database.
 11. Acomputer program product for managing data records in a relationaldatabase, the computer program product comprising a computer readablestorage medium having program instructions embodied therewith, whereinthe computer readable storage medium is not a transitory signal per se,the program instructions executable by a processor to cause theprocessor to perform a method comprising: receiving an operator commandto replace a first variable data record with a second variable datarecord in a relational database, wherein the first variable data recordis associated with a record length, a page of memory, an amount of freespace in the page, and a page length of the page; determining, by theprocessor, based upon receiving the operator command, whether anestimated record length of a compressed second variable data record isoutside of the amount of free space in the page; and in response todetermining that the estimated record length of the compressed secondvariable data record is within the page length, compressing the secondvariable data record in the relational database.
 12. The computerprogram product of claim 11, wherein determining whether the estimatedrecord length of a compressed second variable data record is outside ofthe page length further comprises: estimating a length of a compressedpage; and comparing, in response to estimating, the estimated recordlength of the compressed page with the page length.
 13. The computerprogram product of claim 12, wherein in response to determining that theestimated record length of the compressed page is within the pagelength, the method further comprises: compressing the page; andreplacing the page with a compressed page.
 14. The computer programproduct of claim 12, wherein comparing the estimated record length ofthe compressed page with the page length further comprises: determiningthe estimated record length of the compressed page is outside of thepage length; and creating an overflow record for the second variabledata record.
 15. The computer program product of claim 11, wherein theoperator command corresponds with modifier commands, the modifiercommands including update operators.
 16. A computer system for managingdata records in a relational database, the computer system comprising: amemory; and a processor in communication with the memory, wherein theprocessor is configured to perform a method, the method comprising:receiving an operator command to replace a first data record with asecond data record in a relational database, wherein the first datarecord is associated with a record length, a page of memory, an amountof free space in the page, and a page length of the page; determining,by the processor, based upon receiving the operator command, whether anestimated record length of a compressed second data record is outside ofthe amount of free space in the page; and in response to determiningthat the estimated record length of the compressed second data record iswithin the page length, compressing the second data record in therelational database.
 17. The computer system of claim 16, whereinreceiving the operator command includes comparing the record length ofthe second data record with the amount of free space in the page. 18.The computer system of claim 17, further comprising: determining, basedon comparing the record length of the second data record with the amountof free space in the page, the record length of the second data recordto be within the amount of free space in the page; and replacing thefirst data record with the second data record.
 19. The computer systemof claim 16, wherein determining whether an estimated record length of acompressed second data record is outside of the amount of free space inthe page further comprises: comparing the record length of the seconddata record with the amount of free space in the page; estimating, inresponse to comparing, a record length of a compressed second datarecord; and comparing, in response to estimating, the estimated recordlength of the compressed second data record with the amount of freespace in the page.
 20. The computer system of claim 19, furthercomprising: determining, based upon the comparing, the estimated recordlength of the compressed second data record is within the amount of freespace in the page; compressing the second data record; and replacing thefirst data record with the compressed second data record.